package com.qf.test;

import org.junit.Test;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

import java.util.HashSet;
import java.util.Set;

/**
 * Jedis连接Redis集群
 * @author zjw
 */
public class Demo5 {

    @Test
    public void cluster(){
        Set<HostAndPort> nodes = new HashSet<>();
        nodes.add(new HostAndPort("192.168.41.98",7001));
        nodes.add(new HostAndPort("192.168.41.98",7002));
        nodes.add(new HostAndPort("192.168.41.98",7003));
        nodes.add(new HostAndPort("192.168.41.98",7004));
        nodes.add(new HostAndPort("192.168.41.98",7005));
        nodes.add(new HostAndPort("192.168.41.98",7006));

        JedisCluster jedisCluster = new JedisCluster(nodes);

        jedisCluster.set("name","lisi");
    }

}
